package com.zhiwang.planet.widget

import android.content.Context
import androidx.appcompat.app.AlertDialog
import android.view.LayoutInflater
import com.zhiwang.planet.R
import kotlinx.android.synthetic.main.nickname_edit_dialog_layout.view.*

class NickNameEditorDialog {


    companion object {
        fun create(context: Context, listener: OnPromoteListener): AlertDialog {
            val layoutInflater = LayoutInflater.from(context)
            val view = layoutInflater.inflate(R.layout.nickname_edit_dialog_layout, null)
            val alertDialog = AlertDialog.Builder(context, R.style.InputDialogInputStyle)
                    .setView(view)
                    .create()

            view.dialog_button.setOnClickListener {
                listener.onPromote(view.nicknameEditor.text.toString())
            }

            view.closeBtn.setOnClickListener {
                alertDialog.dismiss()
            }
            return alertDialog
//            alertDialog.window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
        }

        interface OnPromoteListener {
            fun onPromote(pwd: String)
        }
    }
}

